<style>
    .custom-toolbar{padding: 0em 1em 1em 0em;}
</style>
<div class="row-fluid clearfix">
    <div class="col-md-12 column">
        <ul class="breadcrumb">
            <li>
                <a href="index.html">首页</a>
            </li>
            <li class="active">
                设备初始化
            </li>
        </ul>
    </div>
    <div class="col-md-12 column">
        <div class="col-sm-12 div-page">
            <div class="col-sm-12 div-table">
                <div id="custom-toolbar" class="col-sm-12 custom-toolbar">
                    <button id="btn-DataInitPwd" type="button" role="button" class="subFun btn btn-sm btn-primary" data="1">
                        <span class="glyphicon glyphicon-refresh"></span> 锁屏密码
                    </button>
                    <button id="btn-DataInitLocation" type="button" role="button" class="subFun btn btn-sm btn-primary" data="2">
                        <span class="glyphicon glyphicon-refresh"></span> 定位信息
                    </button>
                    <button id="btn-Filter" type="button" href="#modal-Filter" role="button" data-toggle="modal" class="btn btn-sm btn-primary pull-right" title="请选择数据">
                        <span class="glyphicon glyphicon-th-list"></span> 筛选
                    </button>
                </div>
                <table id="table" class="table table-hover table-condensed"
                       data-click-to-select="true"  data-height="410">
                    <thead>
                    <tr>
                        <th data-field="state" data-checkbox="true" ></th>
                        <th data-field="OrgText" data-halign="center" data-align="center" data-width="150">归属机构</th>
                        <th data-field="UseName" data-halign="center" data-align="center" data-width="150">客户姓名</th>
                        <th data-field="TermId" data-halign="center" data-align="center" data-width="200">终端编号</th>
                        <th data-field="PadId" data-halign="center" data-align="center" data-width="200">安全设备号</th>
                        <th data-field="CartId" data-halign="center" data-align="center" data-width="200">证件号码</th>
                        <th data-field="CardNo" data-halign="center" data-align="center" data-width="200">绑定卡号</th>
                        <th data-field="CreatDate" data-halign="center" data-align="center" data-width="150">开户日期</th>
                        <th data-field="Tel_stateText" data-halign="center" data-align="center" data-width="150">终端状态</th>
                        <th data-field="UserTypeText" data-halign="center" data-align="center" data-width="150">用户类型</th>
                        <th data-field="Phone" data-halign="center" data-align="center" data-width="150">联系电话</th>
                        <th data-field="InstallAddr" data-halign="center" data-align="center" data-width="500">布放地址</th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="col-sm-12 alert alert-success div-alert" id="events-result" data-es="Aquí se muestra el resultado del evento"></div>
        <!-- #筛选条件遮罩层 --->
        <div class="modal fade" id="modal-Filter" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <div class="modal-title" id="myModalLabel1">
                            筛选条件
                        </div>
                    </div>
                    <form id="queryForm" method="post" class="form-horizontal layer_msg">
                        <div class="modal-body">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">所属机构</label>
                                <div class="col-sm-8">
                                    <input type="hidden" class="form-control" name="OrgId" id="OrgId"/>
                                    <input type="hidden" class="form-control" name="OrgName" id="OrgName"/>
                                    <div class="col-md-4" style="padding-left: 0;padding-right: 2px">
                                        <select class="form-control" id="level1">
                                        </select>
                                    </div>
                                    <div class="col-md-4" style="padding-left: 0;padding-right: 2px;display: none">
                                        <select class="form-control" id="level2">
                                        </select>
                                    </div>
                                    <div class="col-md-4" style="padding-left: 0;padding-right: 0;display: none">
                                        <select class="form-control" id="level3">
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">客户姓名</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="UseName"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">证件号码</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="CartId"/>
                                </div>
                            </div>
                            <div class="form-group hidden">
                                <label class="col-sm-3 control-label">用户类型</label>
                                <div class="col-sm-8">
                                    <select class="form-control" id="userType" name="UserType">
                                        //动态加载
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">绑定卡号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="CardNo"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">联系电话</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="Phone"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">终端编号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="TermId"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">安全设备号</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control" name="PadId"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">终端状态</label>
                                <div class="col-sm-8">
                                    <select class="form-control" name="Tel_state">
                                        <option value="">全部</option>
                                        <option value="03">待绑定</option>
                                        <option value="01">正常</option>
                                        <option value="04">待复核</option>
                                        <option value="05">复核未通过</option>
                                        <option value="02">已解绑</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button id="modal-btn-query" type="submit" class="btn btn-primary" data-dismiss="modal">查询</button> <button id="modal-btn-close1" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
$(function () {
    /*表格初始化_add_ywq_20150402-Start*/
    $('#table').bootstrapTable({
        queryParams:function(params) {
            var qp={
                page:params.offset/params.limit+1,
                rows:params.limit
            };
            return qp;
        },
        data:[],
        sidePagination: 'server',
        pagination:true,
        pageSize:10,
        search:false,
        responseHandler:function(data){
            return data.data;
        }
    })
            .on('click-row.bs.table', function (e, row, $element) {
                if ( $element.hasClass('selected') ) {
                    $element.removeClass('info');
                }
                else {
                    $element.parent('tbody').find(' > tr.selected ').removeClass("info");
                    $element.addClass('info');
                }
            })
            .on('check.bs.table', function (e, row, $element) {
                $(".btn-Data").removeClass("disabled");
            })
            .on('uncheck.bs.table', function (e, row, $element) {
                $(".btn-Data").addClass("disabled");
            });
    /*表格初始化_add_ywq_20150402-End*/

    /*筛选框下拉列表数据初始化_add_ywq_20150402-Start*/
    OrgSelectInit();
    FormatSelect(globalUrl+"api/Dict?Typeid=0000000007",$("#userType"),"全部","",function(){
        $('#modal-Filter').modal('show');
    });
    /*筛选框下拉列表数据初始化_add_ywq_20150402-End*/


    /*筛选框查询按钮点击事件注册_add_ywq_20150402-Start*/
    $("#modal-btn-query").click(function(e){
        $("#OrgId").val(localStorage.orgid);
        $(".btn-Data").addClass("disabled");
        $('#table').bootstrapTable("destroy");
        $('#table').bootstrapTable({
            queryParams:function(params) {
                var qp={
                    page:params.offset/params.limit+1,
                    rows:params.limit
                };
                return qp;
            },
            url:globalUrl+"api/Device?"+$("#queryForm").serialize(),
            sidePagination: 'server',
            pagination:true,
            pageSize:10,
            search:false,
            responseHandler:function(data){
                return data.data;
            }
        })
                .on('click-row.bs.table', function (e, row, $element) {
                    if ( $element.hasClass('selected') ) {
                        $element.removeClass('info');
                    }
                    else {
                        $element.parent('tbody').find(' > tr.selected ').removeClass("info");
                        $element.addClass('info');
                    }
                })
                .on('check.bs.table', function (e, row, $element) {
                    $(".btn-Data").removeClass("disabled");
                })
                .on('uncheck.bs.table', function (e, row, $element) {
                    $(".btn-Data").addClass("disabled");
                });
    });
    /*筛选框查询按钮点击事件注册_add_ywq_20150402-End*/


    /*子功能按钮事件注册_add_ywq_20150402-Start*/
    $(".subFun").click(function(e){
        var rows=$('#table').bootstrapTable('getSelections');
        var len=rows.length;
        if(len>0)
        {
            var flag=confirm("确认初始化锁屏密码和定位信息吗？");
            if(flag)
            {
                var safeIds=[];
                for(var i=0;i<len;i++)
                {
                    safeIds.push(rows[i].PadId);

                }
                console.log(safeIds);
                $.ajax({
                    type: "get",
                    url: globalUrl+"api/InitDeviPass?initType="+$(e.target).attr("data")+"&initDevice="+safeIds,
                    success: function (resp) {
                        if(resp.result)
                        {
                            alert("操作成功！");
                        }
                        else
                        {
                            alert(resp.msg);
                        }
                    },
                    error:function(){
                        alert("后台未成功返回！");
                    }
                });
            }
        }
        else
        {
            alert("请至少选择一行！");
        }


    });
    /*子功能按钮事件注册_add_ywq_20150402-End*/
});
</script>